<!DOCTYPE html>
<html>
<head>
    <title>设计模式</title>
</head>
<body>
<script>
    Function.prototype.method = function(name,fn){
        this.prototype[name] = fn;
    }

    var Anim = function(){}
    Anim.method("start",function(){
        alert("start");
    });
    Anim.method("stop",function(){
        alert("stop");
    });

    var anim = new Anim();
    anim.start();
    anim.stop();

// ---------------------------------------------
    var Controller = {};
    (Controller.users = function($){
        var nameClick = function(){};
        $(function(){
            $("#view .name").click(nameClick);
        });
    })(jQuery);
// ---------------------------------------------

var assert = function(value, msg) {
    if ( !value )
    throw(msg || (value + " does not equal true"));
};
var assertEqual = function(val1, val2, msg) {
    if (val1 !== val2)
    throw(msg || (val1 + " does not equal " + val2));
};

var klass = function(){
    var klass = function(){
        this.init.apply(this, arguments);
    };
    klass.prototype.init = function(){};
}

</script>
</body>
</html>